//
//  SEGRegisterLeftView.m
//  Login
//
//  Created by 梁昆 on 16/8/16.
//  Copyright © 2016年 segiK. All rights reserved.
//
#import "SEGRegisterLeftView.h"

@interface SEGRegisterLeftView () <UITextFieldDelegate, SGETextFieldLimitDelegate>

@property (nonatomic, strong) dispatch_source_t timer;

@end

@implementation SEGRegisterLeftView

- (instancetype)init
{
    if (self == [super init]) {

        self.backgroundColor = [UIColor whiteColor];

        //注册标题
        [self addSubview:self.titleRegister];
        [self.titleRegister mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top).mas_offset(40);
            make.centerX.equalTo(self.mas_centerX);
        }];
        
        //返回按钮
        [self addSubview:self.goBackBtn];
        [self.goBackBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).mas_offset(15);
            make.width.mas_equalTo(50);
            make.height.mas_equalTo(50);
            make.centerY.equalTo(self.titleRegister);
        }];
        
        //手机号-线
        [self addSubview:self.line1View];
        [self.line1View mas_makeConstraints:^(MASConstraintMaker* make) {
            make.top.equalTo(self.mas_top).mas_offset(160);
            make.centerX.equalTo(self.mas_centerX);
            make.height.mas_equalTo(0.5);
            make.left.equalTo(self).offset(60);
            make.right.equalTo(self).offset(-60);
        }];
        
        // 图片验证码-线
        [self addSubview:self.line4View];
        [self.line4View mas_makeConstraints:^(MASConstraintMaker* make) {
            make.top.equalTo(self.line1View).mas_offset(50);
            make.left.equalTo(self.line1View.mas_left);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(0.5);
        }];
        
        //验证码-线
        [self addSubview:self.line2View];
        [self.line2View mas_makeConstraints:^(MASConstraintMaker* make) {
            make.top.equalTo(self.line4View).mas_offset(50);
            make.centerX.equalTo(self.mas_centerX);
            make.left.equalTo(self).offset(60);
            make.right.equalTo(self).offset(-60);
            make.height.mas_equalTo(0.5);
        }];
        
        //密码-线
        [self addSubview:self.line3View];
        [self.line3View mas_makeConstraints:^(MASConstraintMaker* make) {
            make.top.equalTo(self.line2View).mas_offset(50);
            make.centerX.equalTo(self.mas_centerX);
            make.left.equalTo(self).offset(60);
            make.right.equalTo(self).offset(-60);
            make.height.mas_equalTo(0.5);
        }];
        
        //手机号
        [self addSubview:self.phoneText];
        [self.phoneText mas_makeConstraints:^(MASConstraintMaker* make) {
            //        make.bottom.equalTo(self.line1View.mas_top);
            //        make.left.equalTo(self.line1View.mas_left);
            //        make.width.mas_equalTo(self.line1View).mas_offset(-10);
            //        make.height.mas_equalTo(13 + 22);
            make.bottom.equalTo(self.line1View.mas_top);
            make.left.equalTo(self.line1View.mas_left);
            make.width.mas_equalTo(self.line1View).mas_offset(-10);
            make.height.mas_equalTo(13 + 22);
        }];
        
        // 清空手机号按钮
        [self addSubview:self.cleanPhoneButton];
        [self.cleanPhoneButton mas_makeConstraints:^(MASConstraintMaker* make) {
            make.bottom.equalTo(self.line1View.mas_top).mas_offset(-6);
            make.right.equalTo(self.line1View.mas_right);
            make.width.mas_equalTo(24);
            make.height.mas_equalTo(24);
        }];
        
        // 图片验证码输入框
        [self addSubview:self.checkImgText];
        [self.checkImgText mas_makeConstraints:^(MASConstraintMaker* make) {
            make.bottom.equalTo(self.line4View.mas_top);
            make.left.equalTo(self.line4View.mas_left);
            make.width.mas_equalTo(self.line4View).mas_offset(-10);
            make.height.mas_equalTo(13 + 22);
        }];
        
        [self.freshCheckImgBtn sizeToFit];
        
        // 验证码图片
        [self addSubview:self.checkImgView];
        [self addSubview:self.freshCheckImgBtn];

        [self.checkImgView mas_makeConstraints:^(MASConstraintMaker* make) {
            make.bottom.equalTo(self.line4View.mas_top);
            make.right.equalTo(self.freshCheckImgBtn.mas_left).mas_offset(-15 * kScaleWidth);
//            make.right.equalTo(self.line1View.mas_right).mas_offset(-(15 + self.freshCheckImgBtn.bounds.size.width) * kScaleWidth);
            make.width.mas_equalTo(72 * kScaleWidth);
            make.height.mas_equalTo(30 * kScaleHeight);
        }];
        
        // 验证码刷新按钮
        [self.freshCheckImgBtn mas_makeConstraints:^(MASConstraintMaker* make) {
            make.right.equalTo(self.line1View.mas_right);
            make.centerY.equalTo(self.checkImgView);
        }];
        
        
        // 验证码
        [self addSubview:self.checkText];
        [self.checkText mas_makeConstraints:^(MASConstraintMaker* make) {
            make.bottom.equalTo(self.line2View.mas_top);
            make.left.equalTo(self.line2View.mas_left);
            make.width.mas_equalTo(170);
            make.height.mas_equalTo(13 + 22);
        }];
        
        //验证码按钮
        [self addSubview:self.getMessButton];
        [self.getMessButton mas_makeConstraints:^(MASConstraintMaker* make) {
            make.bottom.equalTo(self.line2View.mas_top);
            make.right.equalTo(self.line2View.mas_right);
            make.height.mas_equalTo(40);
        }];
        
        //密码
        [self addSubview:self.passwordText];
        [self.passwordText mas_makeConstraints:^(MASConstraintMaker* make) {
            make.bottom.equalTo(self.line3View.mas_top);
            make.left.equalTo(self.line3View.mas_left);
            make.width.mas_equalTo(self.line3View);
            make.height.mas_equalTo(13 + 22);
        }];
        
        //语音验证码
        [self addSubview:self.getSoundMsgLabel];
        [self addSubview:self.getSoundMsgButton];
        [self.getSoundMsgLabel mas_makeConstraints:^(MASConstraintMaker* make) {
            make.top.equalTo(self.line3View.mas_bottom).mas_offset(10);
            make.right.equalTo(self.getSoundMsgButton.mas_left);
            make.width.mas_greaterThanOrEqualTo(50);
            make.height.mas_equalTo(11);
        }];
        
        // 语音验证码按钮
        [self.getSoundMsgButton mas_makeConstraints:^(MASConstraintMaker* make) {
            make.centerY.equalTo(self.getSoundMsgLabel.mas_centerY);
            make.right.equalTo(self.line3View.mas_right);
            make.width.mas_greaterThanOrEqualTo(50);
            make.height.mas_equalTo(20);
        }];
        
        [self addSubview:self.passwordRuleLabel];
        [self.passwordRuleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.line3View.mas_left);
            make.right.equalTo(self.line3View.mas_right);
            make.top.equalTo(self.getSoundMsgButton.mas_bottom).offset(6);
        }];
        
        // 确定 按钮
        [self  addSubview:self.nextButton];
        [self.nextButton mas_makeConstraints:^(MASConstraintMaker* make) {
            make.top.equalTo(self.line3View.mas_bottom).mas_offset(55+30);
            make.centerX.equalTo(self.mas_centerX);
            make.width.mas_equalTo(LYDistanceV(260));
            make.height.mas_equalTo(40);
        }];
        
        //计算按钮文本的宽高
        CGSize size = [self.gotoLogin.titleLabel.text boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size;
        
        //提示用户，去登陆按钮
        [self.gotoLogin sizeToFit];
        [self addSubview:self.gotoLogin];
        [self.gotoLogin mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.nextButton.mas_bottom).mas_offset(20 * kScaleHeight);
            make.height.mas_equalTo(size.height);
            make.centerX.equalTo(self.mas_centerX);
        }];
    }

    return self;
}

#pragma mark - RegiserDelegate
//返回按钮的点击方法
-(void)goBackBtnToClick{
    [self.delegate goBackBtnToLoginClick];
}

//刷新验证码
-(void)freshCheckImgBtnClick{
    [self.delegate freshCheckImg];
}

//提示用户，去登陆
-(void)letGotoLogin{
    [self.delegate GotoLogin];
}

//清空手机号
- (void)cleanPhoneText
{
    self.phoneText.text = nil;
    self.cleanPhoneButton.hidden = YES;
}

//发送验证码
- (void)getmessage
{
    if ([self checkPhoneNumber]) {
        [self.delegate getMessage:@{ @"tel" : self.phoneText.text }];
    }
}

// 获取语音验证码
- (void)getSoundMessage
{
    if ([self checkPhoneNumber]) {
        [self.delegate getSoundMessageWithTel:self.phoneText.text type:@"register"];
    }
}

// 检测手机号
- (BOOL)checkPhoneNumber
{
    if (self.phoneText.text.length == 0) {
        [SEGAlertView showTmepMessageWithMessage:@"请输入手机号"];
        return NO;
    }
    else if (self.phoneText.text.length != 11) {
        [SEGAlertView showTmepMessageWithMessage:@"请输入正确的手机号码"];
        return NO;
    }else if (self.checkImgText.text.length == 0) {
        [SEGAlertView showTmepMessageWithMessage:@"请输入图片验证码"];
        return NO;
    }
    
    return YES;
}

- (void)setCode:(NSString*)code
{
    _code = code;
}

//注册界面“下一步”按钮的代理方法实现
- (void)nextButtonClick
{
    [self endEditing:YES];
    
    if (self.phoneText.text.length != 11) {
        [SEGAlertView showTmepMessageWithMessage:@"请输入正确的手机号码"];
        return;
    }

    [self.delegate nextClick:@{ @"tel" : self.phoneText.text,
                                @"smsCode" : self.checkText.text,
                                @"password" : self.passwordText.text
    }];
}

#pragma mark - <SGETextFieldLimitDelegate>
- (void)limitTextFileDidChange:(UITextField *)textField {
    self.cleanPhoneButton.hidden = self.phoneText.text.length == 0;
    [self setConfirmButtonStatusWithPhoneLength:self.phoneText.text.length
                                 passwordLength:self.passwordText.text.length
                                checkTextLength:self.checkText.text.length
                             checkImgTextLength:self.checkImgText.text.length];
}

#pragma mark - 方法实现
- (BOOL)textFieldShouldReturn:(UITextField*)textField
{
    if (textField == self.checkText) {
        [self.checkText resignFirstResponder];
    }
    else if (textField == self.passwordText) {
        [self.passwordText resignFirstResponder];
    }
    else if (textField == self.checkImgText) {
        [self.checkImgText resignFirstResponder];
    }
    return YES;
}

- (void)setConfirmButtonStatusWithPhoneLength:(NSUInteger)phoneLength
                               passwordLength:(NSUInteger)passwordLength
                              checkTextLength:(NSUInteger)checkTextLength
                           checkImgTextLength:(NSUInteger)checkImgTextLength

{
    if (phoneLength > 0 && passwordLength >= 8 && checkTextLength > 0 && checkImgTextLength > 0) {
        self.nextButton.enabled = YES;
    }else {
        self.nextButton.enabled = NO;
    }
}

//计时器发送验证码
- (void)sentPhoneCodeTimeMethod
{
    if (self.timer) {
        dispatch_cancel(self.timer);
    }
    //清空短信验证码
    self.checkText.text = nil;
    //清空验证码的时候 按钮状态需要重置
    self.nextButton.enabled = NO;
    //倒计时时间 —— 60秒
    __block NSInteger timeOut = 59;
    //执行队列
    dispatch_queue_t queque = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    //计时器－》dispatch_source_set_timer自动生成
    self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queque);
    dispatch_source_set_timer(self.timer, DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
    WeakSelf;
    dispatch_source_set_event_handler(self.timer, ^{
        if (timeOut <= 0) {
            dispatch_source_cancel(weakSelf.timer);
            //主线程设置按钮样式
            dispatch_async(dispatch_get_main_queue(), ^{
                [weakSelf.getMessButton setTitle:kRefreshGetMessageCodeTitle forState:UIControlStateNormal];
                weakSelf.getMessButton.enabled = YES;
                weakSelf.getSoundMsgButton.enabled = YES;
            });
        }
        else {
            //开始计时
            //剩余秒数  seconds
            NSInteger seconds = timeOut % 60;
            NSString* strTime = [NSString stringWithFormat:@"%.1ld", (long)seconds];
            //主线程设置按钮样式
            dispatch_async(dispatch_get_main_queue(), ^{
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationDuration:1.0];
                [weakSelf.getMessButton setTitle:[NSString stringWithFormat:@"%@S", strTime] forState:UIControlStateNormal];
                weakSelf.getMessButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;                [UIView commitAnimations];
                //计时器件不允许点击
                weakSelf.getMessButton.enabled = NO;
                weakSelf.getSoundMsgButton.enabled = NO;
            });
            timeOut--;
        }
    });
    dispatch_resume(self.timer);
}

#pragma mark - getter  控件视图
// 注册标题
-(UILabel *)titleRegister{
    if (!_titleRegister) {
        _titleRegister = [[UILabel alloc] init];
        _titleRegister.text = @"注册";
        _titleRegister.font = [UIFont systemFontOfSize:18];
        _titleRegister.textColor = kColor_1;
    }
    return _titleRegister;
}

//返回按钮
-(UIButton *)goBackBtn{
    if (!_goBackBtn) {
        _goBackBtn = [[UIButton alloc] init];
        [_goBackBtn setImage:[UIImage imageWithContentsOfFile:SEGPicName(@"back")] forState:UIControlStateNormal];
        
        _goBackBtn.backgroundColor = [UIColor clearColor];
        [_goBackBtn addTarget:self action:@selector(goBackBtnToClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _goBackBtn;
}

//第一根灰色分割线
- (UIView*)line1View
{
    if (!_line1View) {
        _line1View = [[UIView alloc] init];
        _line1View.backgroundColor = kColor_L2;
    }
    return _line1View;
}

- (UIView*)line2View
{
    if (!_line2View) {
        _line2View = [[UIView alloc] init];
        _line2View.backgroundColor = kColor_L2;
    }
    return _line2View;
}

- (UIView*)line3View
{
    if (!_line3View) {
        _line3View = [[UIView alloc] init];
        _line3View.backgroundColor = kColor_L2;
    }
    return _line3View;
}

- (UIView*)line4View
{
    if (!_line4View) {
        _line4View = [[UIView alloc] init];
        _line4View.backgroundColor = kColor_L2;
    }
    return _line4View;
}

//清空电话按钮
- (UIButton*)cleanPhoneButton
{
    if (!_cleanPhoneButton) {
        //发送验证码 按钮
        _cleanPhoneButton = [[UIButton alloc] init];
        [_cleanPhoneButton setImage:[UIImage imageWithContentsOfFile:SEGPicName(@"icon_list_delete")] forState:UIControlStateNormal];
        [_cleanPhoneButton addTarget:self action:@selector(cleanPhoneText) forControlEvents:UIControlEventTouchUpInside];
        _cleanPhoneButton.hidden = YES;
    }
    return _cleanPhoneButton;
}

//获取验证码按钮
- (UIButton*)getMessButton
{
    if (!_getMessButton) {
        //发送验证码 按钮
        _getMessButton = [[UIButton alloc] init];
        [_getMessButton setTitle:kGetMessageCodeTitle forState:UIControlStateNormal];
        _getMessButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;                [UIView commitAnimations];
        _getMessButton.titleLabel.font = [UIFont systemFontOfSize:13];
        [_getMessButton setTitleColor:kColor_T forState:UIControlStateNormal];
        [_getMessButton setTitleColor:kColor_3 forState:UIControlStateDisabled];
        //设置圆角
        [_getMessButton.layer setCornerRadius:3.0f];
        [_getMessButton.layer setShouldRasterize:YES];
        [_getMessButton.layer setRasterizationScale:[UIScreen mainScreen].scale];
        //发送事件
        [_getMessButton addTarget:self action:@selector(getmessage) forControlEvents:UIControlEventTouchUpInside];
    }
    return _getMessButton;
}

//下一步按钮
- (UIButton*)nextButton
{
    if (!_nextButton) {
        _nextButton = [[UIButton alloc] init];
        [_nextButton setTitle:@"确定" forState:UIControlStateNormal];
        _nextButton.titleLabel.font = [UIFont systemFontOfSize:16];
        [_nextButton setTitleColor:kColor_W forState:UIControlStateNormal];
        _nextButton.layer.masksToBounds = YES;
        _nextButton.layer.cornerRadius = 20;
        _nextButton.backgroundColor = kColor_T;
        [_nextButton setBackgroundImage:[UIImage imageWithColor:kColor_T] forState:UIControlStateNormal];
        [_nextButton setBackgroundImage:[UIImage imageWithColor:kColor_T_Press] forState:UIControlStateHighlighted];
        [_nextButton setBackgroundImage:[UIImage imageWithColor:kColor_L2] forState:UIControlStateDisabled];
        [_nextButton addTarget:self action:@selector(nextButtonClick) forControlEvents:UIControlEventTouchUpInside];
        _nextButton.enabled = NO;
    }
    return _nextButton;
}

//输入手机号码textfield
- (UITextField*)phoneText
{
    if (!_phoneText) {
        _phoneText = [[UITextField alloc] init];
        [_phoneText setTextColor:kColor_1];
        [_phoneText setFont:[UIFont systemFontOfSize:13]];
        [_phoneText setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:@"手机号" attributes:@{NSForegroundColorAttributeName:kColor_C}]];
        _phoneText.clearsOnBeginEditing = NO;
        _phoneText.delegate = self;
        _phoneText.clearButtonMode = UITextFieldViewModeNever;
        _phoneText.keyboardType = UIKeyboardTypeNumberPad;
        _phoneText.returnKeyType = UIReturnKeyDone;
        [_phoneText setTintColor:kColor_T];
        [_phoneText configPhoneInputLimitWithDelegate:self];
    }
    return _phoneText;
}

//图片验证码
- (UITextField*)checkImgText
{
    if (!_checkImgText) {
        _checkImgText = [[UITextField alloc] init];
        [_checkImgText setTextColor:kColor_1];
        [_checkImgText setFont:[UIFont systemFontOfSize:13]];
        _checkImgText.placeholder = @"图片验证码";
        _checkImgText.clearsOnBeginEditing = NO;
        _checkImgText.delegate = self;
        [_checkImgText setTintColor:kColor_T];
        _checkImgText.keyboardType = UIKeyboardTypeAlphabet;
        _checkImgText.clearButtonMode = UITextFieldViewModeNever;
        _checkImgText.returnKeyType = UIReturnKeyDone;
        _checkImgText.autocapitalizationType = UITextAutocapitalizationTypeNone;
        _checkImgText.autocorrectionType = UITextAutocorrectionTypeNo;
        [_checkImgText configImgCodeInputLimitWithDelegate:self];
    }
    return _checkImgText;
}

-(UIImageView *)checkImgView{
    if (!_checkImgView) {
        _checkImgView = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:SEGPicName(@"pic_default_72_72")]];
        [_checkImgView setUserInteractionEnabled:YES];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(freshCheckImgBtnClick)];
        [_checkImgView addGestureRecognizer:tap];
    }
    return _checkImgView;
}

//输入验证码textfield
- (UITextField*)checkText
{
    if (!_checkText) {
        _checkText = [[UITextField alloc] init];
        [_checkText setTextColor:kColor_1];
        [_checkText setTintColor:kColor_T];
        [_checkText setFont:[UIFont systemFontOfSize:13]];
        [_checkText setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:@"手机验证码" attributes:@{NSForegroundColorAttributeName:kColor_C}]];
        _checkText.clearsOnBeginEditing = NO;
        _checkText.keyboardType = UIKeyboardTypeNumberPad;
        _checkText.returnKeyType = UIReturnKeyDone;
        _checkText.delegate = self;
        [_checkText configSMSCodeInputLimitWithDelegate:self];
    }
    return _checkText;
}

//输入密码textfield
- (SEGPasswordTextField*)passwordText
{
    if (!_passwordText) {
        _passwordText = [[SEGPasswordTextField alloc] init];
        [_passwordText setTextColor:kColor_1];
        [_passwordText setTintColor:kColor_T];
        [_passwordText setFont:[UIFont systemFontOfSize:13]];
        [_passwordText setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSForegroundColorAttributeName:kColor_C}]];
        _passwordText.secureTextEntry = YES;
        _passwordText.clearsOnBeginEditing = NO;
        _passwordText.clearButtonMode = UITextFieldViewModeNever;
        _passwordText.returnKeyType = UIReturnKeyDone;
        _passwordText.delegate = self;
        [_passwordText configPasswordInputLimitWithDelegate:self currentView:self];
    }
    return _passwordText;
}

- (UILabel*)getSoundMsgLabel
{
    if (!_getSoundMsgLabel) {
        _getSoundMsgLabel = [[UILabel alloc] init];
        _getSoundMsgLabel.textColor = kColor_1;
        _getSoundMsgLabel.font = [UIFont systemFontOfSize:11];
        _getSoundMsgLabel.text = @"收不到验证码？试试";
    }
    return _getSoundMsgLabel;
}

- (UIButton*)getSoundMsgButton
{
    if (!_getSoundMsgButton) {
        //发送语音验证码 按钮
        _getSoundMsgButton = [[UIButton alloc] init];
        _getSoundMsgButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [_getSoundMsgButton setTitle:@"语音验证码" forState:UIControlStateNormal];
        [_getSoundMsgButton setTitleColor:kColor_S3 forState:UIControlStateNormal];
        [_getSoundMsgButton setTitleColor:kColor_3 forState:UIControlStateDisabled];
        _getSoundMsgButton.titleLabel.font = [UIFont systemFontOfSize:11];
        //发送事件
        [_getSoundMsgButton addTarget:self action:@selector(getSoundMessage) forControlEvents:UIControlEventTouchUpInside];
    }
    return _getSoundMsgButton;
}

- (UIButton*)freshCheckImgBtn
{
    if (!_freshCheckImgBtn) {
        //发送语音验证码 按钮
        _freshCheckImgBtn = [[UIButton alloc] init];
        [_freshCheckImgBtn setTitle:@"换一张" forState:UIControlStateNormal];
        [_freshCheckImgBtn.titleLabel setFont:[UIFont systemFontOfSize:13]];
        [_freshCheckImgBtn setTitleColor:kColor_T forState:UIControlStateNormal];
        _freshCheckImgBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        //发送事件
        [_freshCheckImgBtn addTarget:self action:@selector(freshCheckImgBtnClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _freshCheckImgBtn;
}

//  提示用户去登录
- (UIButton*)gotoLogin
{
    if (!_gotoLogin) {
        _gotoLogin = [[UIButton alloc] init];
        [_gotoLogin setTitle:@"已有账号，去登录" forState:UIControlStateNormal];
        [_gotoLogin setTitleColor:kColor_T forState:UIControlStateNormal];
        _gotoLogin.titleLabel.font = [UIFont systemFontOfSize:13];
        _gotoLogin.tag = 2;
        [_gotoLogin addTarget:self action:@selector(letGotoLogin) forControlEvents:UIControlEventTouchUpInside];
    }
    return _gotoLogin;
}

- (UILabel *)passwordRuleLabel {
    if (!_passwordRuleLabel) {
        _passwordRuleLabel = [[UILabel alloc] init];
        _passwordRuleLabel.textColor = kColor_C;
        _passwordRuleLabel.textAlignment = NSTextAlignmentRight;
        _passwordRuleLabel.font = kFont_11;
        _passwordRuleLabel.numberOfLines = 0;
    }
    return _passwordRuleLabel;
}

@end
